package main

import (
	"fmt"
	"time"
)

func main() {
	c := make(chan int)
	go func() {
		for i := 0; i < 10; i++ {
			c <- i
		}
		close(c)
	}()

	//rang 循环 chan 需要close(c) 否则不会结束
	for v := range c {
		fmt.Println("读取：", v)
		time.Sleep(time.Second)
	}

	time.Sleep(10 * time.Second)
}
